/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pe.gob.pnp.factories;

import java.sql.*;
import javax.naming.*;
import javax.sql.*;

/**
 *
 * @author Javero
 */
public class ConnectionPool {
    public static Connection obtenerConexion() throws SQLException{
        Connection conn=null;
        try{
            Context contexto=new InitialContext();
            DataSource fuente=(DataSource)contexto.lookup("java:comp/env/jdbc/oracle2");
            conn=fuente.getConnection();
        }catch(Exception ex){
            ex.printStackTrace();
            throw new SQLException(ex);
        }
        return conn;
    }

    public static void liberarConexion(Connection conn){
        try{
            if(conn != null) conn.close();
        }catch(SQLException ex){}
    }

}
